package com.zy.web.controller.bs;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zy.entity.bs.CarDealer;
import com.zy.pojo.query.bs.CarDealerQuery;
import com.zy.pojo.vos.common.PageVo;
import com.zy.pojo.vos.common.ResultVo;
import com.zy.service.bs.CarDealerService;
import com.zy.web.controller.base.BaseController;
import com.zy.web.utils.ResultUtil;

@RequestMapping("bs/carDealer")
@Controller
public class CarDealerController extends BaseController {

	@Autowired
	private CarDealerService carDealerService;

	/**
	 * 分页
 	 * 
 	 * @param carDealerQuery
	 * @param start
	 * @param limit
	 * @return
	 */
	@RequestMapping("pageCarDealer")
	@ResponseBody
	public PageVo pageCarDealer(CarDealerQuery carDealerQuery, Integer start, Integer limit) {
		return this.carDealerService.pageCarDealer(carDealerQuery, start, limit);
	}

	/**
	 * 新增
	 * 
	 * @param carDealer
	 * @return
	 */
	@RequestMapping(value = "saveCarDealer", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo saveCarDealer(CarDealer carDealer) {
		try {
			this.carDealerService.saveCarDealer(carDealer);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}
	
	/**
	 * 更新
	 * 
	 * @param carDealer
	 * @return
	 */
	@RequestMapping(value = "updateCarDealer", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo updateCarDealer(CarDealer carDealer) {
		try {
			this.carDealerService.updateCarDealer(carDealer);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}

	/**
	 * 删除
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "removeCarDealer", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo removeCarDealer(long id) {
		try {
			this.carDealerService.removeCarDealer(id);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}

	/**
	 * 恢复
	 * 
	 * @param id
	 * @return
	 */
	@RequestMapping(value = "recover", method = RequestMethod.POST)
	@ResponseBody
	public ResultVo recover(long id) {
		try {
			this.carDealerService.recover(id);
			return ResultUtil.success();
		} catch (Exception e) {
			return ResultUtil.error(log, e);
		}
	}

}